package com.leetcode.No3115;

import org.junit.Test;

import java.util.Arrays;

public class Solution {
    public int maximumPrimeDifference(int[] nums) {
        boolean[] mark = new boolean[]{false, false, true, true, false, true, false, true, false, false, false, true, false, true, false, false, false, true, false, true, false, false, false, true, false, false, false, false, false, true, false, true, false, false, false, false, false, true, false, false, false, true, false, true, false, false, false, true, false, false, false, false, false, true, false, false, false, false, false, true, false, true, false, false, false, false, false, true, false, false, false, true, false, true, false, false, false, false, false, true, false, false, false, true, false, false, false, false, false, true, false, false, false, false, false, false, false, true, false, false, false};
        int left = 0;
        while (left < nums.length && !mark[nums[left]]) {
            ++left;
        }
        int right = nums.length - 1;
        while (right >= 0 && !mark[nums[right]]) {
            --right;
        }
        return right - left;
    }

    @Test
    public void test() {
        int[] nums = new int[]{4,2,9,5,3};
        System.out.println(maximumPrimeDifference(nums));
    }

    @Test
    public void test1() {
        boolean[] mark = new boolean[101];
        mark[1] = true;
        for (int i = 2; i <= 100; ++i) {
            boolean isZ = true;
            for (int j = 2; j < i; ++j) {
                if (i % j == 0) {
                    isZ = false;
                    break;
                }
            }
            mark[i] = isZ;
        }
        System.out.println(Arrays.toString(mark));
    }

    @Test
    public void test2() {
        String str = "1&&2";
        String[] numStrs = str.split("&&");
        int[] nums = new int[numStrs.length];
        for (int i = 0; i < numStrs.length; i++) {
            nums[i] = Integer.parseInt(numStrs[i]);
        }
        // nums数组就是转换后的数字数组
    }
}
